理解工作流 内容 概述 简单工作流 加入1个审核 加入2个审核 概述 1. 新建一个表TT_myTB 2. 新建二个字段, docstatus(_DocumentStatus), docaction(_DocumentActions挂一个流程TT_myPC,流程挂工作流TT_myWF) 3. table-field,docstatus设为只读 简单工作流 开始-准备-完成 加入1个审核 1. 增加表字段ApprovalAmt,IsApproval2 开始--准备--审核--完成 为什么不用IsApproved字段 只对金额审批,没有金额还不行。 isApproved字段自动化程度太高,自动完成单据 MWFNode.java /** * Is this an Approval setp? * @return true if User Approval */ public boolean isUserApproval() { if (!ACTION_UserChoice.equals(getAction())) return false; return getColumn() != null && "IsApproved".equals(getColumn().getColumnName()); } // isApproval MWFActivity.java /****** User Choice ******/ else if (MWFNode.ACTION_UserChoice.equals(action)) { if (log.isLoggable(Level.FINE)) log.fine("UserChoice:AD_Column_ID=" + m_node.getAD_Column_ID()); // Approval if (m_node.isUserApproval() && getPO(trx) instanceof DocAction) { DocAction doc = (DocAction)m_po; boolean autoApproval = false; // Approval Hierarchy if (isInvoker()) { // Set Approver int startAD_User_ID = Env.getAD_User_ID(getCtx()); if (startAD_User_ID == 0) startAD_User_ID = doc.getDoc_User_ID(); int nextAD_User_ID = getApprovalUser(startAD_User_ID, doc.getC_Currency_ID(), doc.getApprovalAmt(), doc.getAD_Org_ID(), startAD_User_ID == doc.getDoc_User_ID()); // own doc if (nextAD_User_ID<=0) { m_docStatus = DocAction.STATUS_Invalid; throw new AdempiereException(Msg.getMsg(getCtx(), "NoApprover")); } // same user = approved autoApproval = startAD_User_ID == nextAD_User_ID; if (!autoApproval) setAD_User_ID(nextAD_User_ID); } else // fixed Approver { MWFResponsible resp = getResponsible(); // MZ Goodwill // [ 1742751 ] Workflow: User Choice is not working if (resp.isHuman()) { autoApproval = resp.getAD_User_ID() == Env.getAD_User_ID(getCtx()); if (!autoApproval && resp.getAD_User_ID() != 0) setAD_User_ID(resp.getAD_User_ID()); } else if(resp.isRole()) { MUserRoles[] urs = MUserRoles.getOfRole(getCtx(), resp.getAD_Role_ID()); for (int i = 0; i < urs.length; i++) { if(urs[i].getAD_User_ID() == Env.getAD_User_ID(getCtx())) { autoApproval = true; break; } } } else if(resp.isOrganization()) { throw new AdempiereException("Support not implemented for "+resp); } else { throw new AdempiereException("@NotSupported@ "+resp); } // end MZ } if (autoApproval && doc.processIt(DocAction.ACTION_Approve) && doc.save()) return true; // done } // approval return false; // wait for user } 加入2个审核 1. 再增加一个表字段,IsApproved3 开始--准备--审核1 审核2--完成